﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using D2DEngine.Core;
using Microsoft.Xna.Framework.Graphics;

namespace D2DEngine.Scene
{
    public class D2DSceneManager
    {
        private static D2DSceneManager instance = new D2DSceneManager();
        private string currentSceneName = null;
        private Dictionary<string, D2DScene> scenes = new Dictionary<string, D2DScene>();


        /// <summary>
        /// The name of the current scene
        /// </summary>
        public string CurrentSceneName
        {
            get { return this.currentSceneName; }
            set { this.currentSceneName = value; }
        }

        /// <summary>
        /// The current scene of the game
        /// </summary>
        public D2DScene CurrentScene
        {
            get { return this.scenes[this.currentSceneName]; }
        }


        public D2DScene GetScene(String sceneName)
        {
            return this.scenes[sceneName];
        }

        /// <summary>
        /// The collection of scenes
        /// </summary>
        public Dictionary<string, D2DScene> Scenes
        {
            get { return this.scenes; }
            set { this.scenes = value; }
        }

        /// <summary>
        /// Instance of the SceneManager
        /// </summary>
        public static D2DSceneManager Instance
        {
            get { return instance; }
        }

        private D2DSceneManager()
        {
        }
        

        /// <summary>
        /// Updates the current scene
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            // Update the scene
            this.scenes[this.currentSceneName].Update(gameTime);            
        }

        /// <summary>
        /// Draws the scenes
        /// </summary>
        /// <param name="spriteBatch"></param>
        public void Draw(SpriteBatch spriteBatch)
        {
            CurrentScene.Draw(spriteBatch);
        }
        
    }
}
